package com.atguigu.gmall.product.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;
import java.util.ArrayList;
import java.util.List;

/**
 * @author: 李旭
 * @create: 2021-07-07 11:47
 **/
@Controller
@RequestMapping("/hello")
public class HelloController {

    //测试
    @GetMapping("/index")
    public String index(Model model, HttpSession session){
        model.addAttribute("world","世界你好");
        //request.setAttribute(world,世界你好）
        session.setAttribute("hello","打招呼");
        List<String> list  =new ArrayList<>();
        list.add("曾志伟 ");
        list.add("梁超伟");
        list.add("刘德货");
        model.addAttribute("list",list);

        model.addAttribute("num",8);

        model.addAttribute("gname","<span style=\"color:green\">宝强</span>");


        return "hello";
    }
}
